package com.hsnn.medstgmini.pro.project.controller;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.base.std.model.StdCompdrugprofile;
import com.hsnn.medstgmini.base.std.model.StdCompdrugprofileLog;
import com.hsnn.medstgmini.base.std.model.StdCompinfo;
import com.hsnn.medstgmini.base.std.model.form.StdProdDrugInfoForm;
import com.hsnn.medstgmini.base.std.service.CompDrugProfileManager;
import com.hsnn.medstgmini.base.std.service.StdCompdrugprofileManager;
import com.hsnn.medstgmini.pro.project.model.form.ProdDrugProfileForm;
import com.hsnn.medstgmini.pro.project.service.ProdDrugManager;
import com.hsnn.medstgmini.pro.project.service.ProdDrugProfileManager;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.ImgUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;

/**
 * @category 生产企业药品资质申报管理
 * @author 蔡春龙
 * @date 2015年8月28日
 */
@Controller
@RequestMapping("/prodDrugProfile")
public class ProdDrugProfileController {

	private static final Logger log = Logger
			.getLogger(ProdDrugProfileController.class);
	
	@Autowired
	private CompDrugProfileManager compDrugProfileManager;
	
	@Autowired
	private ProdDrugManager prodDrugManager;
	
	@Autowired
	private ProdDrugProfileManager prodDrugProfileManager;

	@Autowired
	private StdCompdrugprofileManager stdCompdrugprofileManager;

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private HttpSession session;

	/**
	 * @category 获取当前登陆人信息
	 * @author 言科
	 * @date 2015年7月22日 SysUser
	 */
	public SysUser getUser() {
		return (SysUser) session.getAttribute(Constants.USERINFO);
	}

	/**
	 * @category 企业产品资质管理项目列表页面
	 * @date 2015年8月30日
	 * @return
	 */
	@RequestMapping("/toDrugProfileProjectList")
	public String toDrugProfileProjectList() {
		log.info("enter toDrugProfileProjectList method!");
		return "/pro/project/prod/drugProfileProjectList";
	}

	/**
	 * @category 生产企业已提交的产品列表页面
	 * @date 2015年8月30日
	 * @param model
	 * @param projId
	 * @return
	 */
	@RequestMapping("/toAuditedProdDrugList")
	public String toAuditedProdDrugList(Model model, String projId) {
		log.info("enter toAuditedProdDrugList method!");
		model.addAttribute("projId", projId);
		return "/pro/project/prod/auditedProdDrugList";
	}

	/**
	 * @category 跳转企业产品资质申报页面
	 * @date 2015年8月30日
	 * @param model
	 * @param form
	 * @return
	 */
	@RequestMapping("/toProdDrugProfileList")
	public String toProdDrugProfileList(Model model, ProdDrugProfileForm form) {
		log.info("enter toProdDrugProfileList method!");
		model.addAttribute("form", form);
		return "/pro/project/prod/prodDrugProfileList";
	}

	/**
	 * @category 查询企业产品资质列表
	 * @date 2015年8月30日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getProdDrugProfileList")
	@ResponseBody
	public Pagination getProdDrugProfileList(ProdDrugProfileForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setCompId(compId);
					page.setForm(form);
					prodDrugProfileManager.getProdDrugProfileList(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}

	/**
	 * @category 新增/修改产品资质
	 * @author 应晓川
	 * @date 2015年8月21日11:42:43
	 * @return
	 * @return Pagination
	 */
	@RequestMapping("/saveCompDrugProfile")
	@ResponseBody
	public Pagination saveOrUpdateStdCompdrugprofile(
			StdCompdrugprofile stdCompdrugprofile, MultipartFile licence) {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(
				Constants.USERINFO);
		String compId = "";// 企业ID
		StdCompinfo compInfo = user.getInfo();
		if (compInfo != null) {
			compId = compInfo.getCompId();
		}
		FileOutputStream fos = null;
		try {
			List<StdCompdrugprofile> list = stdCompdrugprofileManager
					.getStdCompdrugprofileByName(stdCompdrugprofile
							.getProfileName());

			if (StringUtils.isNotBlank(stdCompdrugprofile.getCompprofileId())) {
				StdCompdrugprofile stdCompdrugprofileFromDb = (StdCompdrugprofile) stdCompdrugprofileManager
						.getUniquerResult(StdCompdrugprofile.class,
								"compprofileId",
								stdCompdrugprofile.getCompprofileId());
				if (stdCompdrugprofileFromDb != null) {
					if (list.size() == 0
							|| list.get(0)
									.getCompprofileId()
									.equals(stdCompdrugprofileFromDb
											.getCompprofileId())) {
						if (licence != null) {
							if (licence.getSize() > 3 * 1024 * 1024) {
								page.setSuccess(false);
								page.setMsg("产品资质图片不能大于3M！");
								return page;
							}
							String name = licence.getOriginalFilename();
							if (!ImgUtil.isImg(name)) {
								page.setSuccess(false);
								page.setMsg("请选择格式正确的图片，图片支持格式：gif, jpg, jpeg, png, bmp！");
								return page;
							}

							int index = name.lastIndexOf(".");
							String suffix = name.substring(index);
							name = ParseDate.parseWithNum(new Date())
									.toString() + suffix;
							String path = session.getServletContext()
									.getRealPath("/");
							path = path.replaceAll("\\\\", "/")
									+ "upload/licence/";

							String filename = path + name;
							File file = new File(filename);
							fos = new FileOutputStream(file);
							InputStream stream = licence.getInputStream();
							byte[] bytes = new byte[1024];
							int length = 0;
							while ((length = stream.read(bytes)) != -1) {
								fos.write(bytes, 0, length);
							}
							fos.flush();
							stream.close();
							stdCompdrugprofileFromDb
									.setProfilePicAddr("upload/licence/" + name);
							stdCompdrugprofileFromDb
									.setProfilePicShortcutAddr("upload/licence/"
											+ name);
						}
						stdCompdrugprofileFromDb
								.setProfileName(stdCompdrugprofile
										.getProfileName());
						stdCompdrugprofileFromDb.setProfileStarttime(DateUtil
								.parseDate(stdCompdrugprofile
										.getProfileStarttimeStr()));
						stdCompdrugprofileFromDb.setProfileEndtime(DateUtil
								.parseDate(stdCompdrugprofile
										.getProfileEndtimeStr()));
						stdCompdrugprofileFromDb.setRemarks(stdCompdrugprofile
								.getRemarks());
						stdCompdrugprofileFromDb.setUpdDatetime(new Date());
						stdCompdrugprofileFromDb.setUpdUser(user.getId());
						if (stdCompdrugprofileManager
								.update(stdCompdrugprofileFromDb)) {
							StdCompdrugprofileLog stdCompdrugprofileLog = new StdCompdrugprofileLog();
							BeanUtils.copyProperties(stdCompdrugprofileLog,
									stdCompdrugprofileFromDb);
							stdCompdrugprofileLog.setLogId(UUID.randomUUID()
									.toString());
							stdCompdrugprofileManager
									.save(stdCompdrugprofileLog);
							page.setMsg("操作成功");
							page.setSuccess(true);
						}

					} else {
						page.setMsg("产品资质名称已被使用！");
						page.setSuccess(false);
					}
				}
			} else {
				if (list.size() == 0)// 名称未重名
				{
					if (licence != null) {

						if (licence.getSize() > 3 * 1024 * 1024) {
							page.setSuccess(false);
							page.setMsg("产品资质不图片能大于3M！");
							return page;
						}
						String name = licence.getOriginalFilename();
						if (!ImgUtil.isImg(name)) {
							page.setSuccess(false);
							page.setMsg("请选择格式正确的资质图片，图片支持格式：gif, jpg, jpeg, png, bmp！");
							return page;
						}

						int index = name.lastIndexOf(".");
						String suffix = name.substring(index);
						name = ParseDate.parseWithNum(new Date()).toString()
								+ suffix;
						String path = session.getServletContext().getRealPath(
								"/");
						path = path.replaceAll("\\\\", "/") + "upload/licence/";

						String filename = path + name;
						File file = new File(filename);
						fos = new FileOutputStream(file);
						InputStream stream = licence.getInputStream();
						byte[] bytes = new byte[1024];
						int length = 0;
						while ((length = stream.read(bytes)) != -1) {
							fos.write(bytes, 0, length);
						}
						fos.flush();
						stream.close();

						stdCompdrugprofile.setCompprofileId(UUID.randomUUID()
								.toString());
						Long gg = System.currentTimeMillis();
						stdCompdrugprofile.setProfileCode("ZZ" + gg.toString());
						stdCompdrugprofile.setProfilePicAddr("upload/licence/"
								+ name);
						stdCompdrugprofile
								.setProfilePicShortcutAddr("upload/licence/"
										+ name);
						stdCompdrugprofile.setProfileStarttime(DateUtil
								.parseDate(stdCompdrugprofile
										.getProfileStarttimeStr()));
						stdCompdrugprofile.setProfileEndtime(DateUtil
								.parseDate(stdCompdrugprofile
										.getProfileEndtimeStr()));
						stdCompdrugprofile.setCompId(compId);
						stdCompdrugprofile
								.setStatus(Constants.STD_COMPDRUGPROFILE_STATUS_1);
						stdCompdrugprofile.setUpdUser(user.getId());
						stdCompdrugprofile.setUpdDatetime(new Date());
						if (stdCompdrugprofileManager.save(stdCompdrugprofile)) {
							StdCompdrugprofileLog stdCompdrugprofileLog = new StdCompdrugprofileLog();
							BeanUtils.copyProperties(stdCompdrugprofileLog,
									stdCompdrugprofile);
							stdCompdrugprofileLog.setLogId(UUID.randomUUID()
									.toString());
							stdCompdrugprofileManager
									.save(stdCompdrugprofileLog);
							page.setMsg("操作成功");
							;
							page.setSuccess(true);
						}
					} else {
						page.setSuccess(false);
						page.setMsg("请上传产品资质图片！");
						return page;
					}
				} else {
					page.setSuccess(false);
					page.setMsg("产品资质名称已被使用！");
					;
					return page;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
		} finally {
			if (fos != null) {
				try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return (page);
	}

	/**
	 * @category 申报产品资质
	 * @date 2015年8月31日
	 * @param array
	 * @return
	 */
	@RequestMapping("/submitProdDrugProfileList")
	@ResponseBody
	public Pagination submitProdDrugProfileList(String array) {
		Pagination page = new Pagination(request);
		try {
			if (StringUtils.isNotBlank(array)) {
				Gson gson = new Gson();
				Type type = new TypeToken<List<ProdDrugProfileForm>>() {
				}.getType();
				List<ProdDrugProfileForm> list = gson.fromJson(array, type);
				prodDrugProfileManager.submitProdDrugProfileList(list,
						getUser());
				page.setSuccess(true);
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}

	/**
	 * @category 企业药品资质审核结果页面
	 * @date 2015年8月31日
	 * @param model
	 * @param form
	 * @return
	 */
	@RequestMapping("/toDrugProfileAuditResultList")
	public String toDrugProfileAuditResultList(Model model,
			ProdDrugProfileForm form) {
		log.info("enter toDrugProfileAuditResultList method!");
		model.addAttribute("form", form);
		return "/pro/project/prod/drugProfileAuditResultList";
	}

	/**
	 * @category 企业药品资质审核结果列表
	 * @date 2015年8月31日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getDrugProfileAuditResultList")
	@ResponseBody
	public Pagination getDrugProfileAuditResultList(ProdDrugProfileForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setCompId(compId);
					page.setForm(form);
					prodDrugProfileManager.getDrugProfileAuditResultList(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}

	/**
	 * @category 生产企业产品资质澄清页面
	 * @date 2015年9月1日
	 * @param model
	 * @param form
	 * @return
	 */
	@RequestMapping("/toDrugProfileComplainList")
	public String toDrugProfileComplainList(Model model,
			ProdDrugProfileForm form) {
		log.info("enter toDrugProfileComplainList method!");
		
		
		// 药品资质类型集合
		List<Map<String, String>> typeList = compDrugProfileManager.getDrugProfileTypeList();
		model.addAttribute("typeList", typeList);
		model.addAttribute("form", form);
		return "/pro/project/prod/prodDrugProfileComplain";
	}

	/**
	 * @category 查询生产企业资质澄清列表
	 * @date 2015年9月1日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getDrugProfileComplainList")
	@ResponseBody
	public Pagination getDrugProfileComplainList(ProdDrugProfileForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setCompId(compId);
					page.setForm(form);
					prodDrugProfileManager.getDrugProfileComplainList(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}

	/**
	 * @category 澄清药品资质
	 * @date 2015年9月1日
	 * @param stdCompdrugprofile
	 * @param licence
	 * @return
	 */
	@RequestMapping("/complainDrugProfile")
	@ResponseBody
	public Pagination complainDrugProfile(
			StdCompdrugprofile stdCompdrugprofile, ProdDrugProfileForm form,
			MultipartFile licence) {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(
				Constants.USERINFO);
		FileOutputStream fos = null;
		try {
			List<StdCompdrugprofile> list = stdCompdrugprofileManager
					.getStdCompdrugprofileByName(stdCompdrugprofile
							.getProfileName());

			if (StringUtils.isNotBlank(stdCompdrugprofile.getCompprofileId())) {
				StdCompdrugprofile stdCompdrugprofileFromDb = (StdCompdrugprofile) stdCompdrugprofileManager
						.getUniquerResult(StdCompdrugprofile.class,
								"compprofileId",
								stdCompdrugprofile.getCompprofileId());
				if (stdCompdrugprofileFromDb != null) {
					if (list.size() == 0
							|| list.get(0)
									.getCompprofileId()
									.equals(stdCompdrugprofileFromDb
											.getCompprofileId())) {
						if (licence != null) {
							if (licence.getSize() > 3 * 1024 * 1024) {
								page.setSuccess(false);
								page.setMsg("开户许可证不能大于3M！");
								return page;
							}
							String name = licence.getOriginalFilename();
							if (!ImgUtil.isImg(name)) {
								page.setSuccess(false);
								page.setMsg("开户许可证请选择图片，图片支持格式：gif, jpg, jpeg, png, bmp！");
								return page;
							}

							int index = name.lastIndexOf(".");
							String suffix = name.substring(index);
							name = ParseDate.parseWithNum(new Date())
									.toString() + suffix;
							String path = session.getServletContext()
									.getRealPath("/");
							path = path.replaceAll("\\\\", "/")
									+ "upload/licence/";
							name = UUID.randomUUID() + ImgUtil.getSuffix(name);
							String filename = path + name;
							File file = new File(filename);
							fos = new FileOutputStream(file);
							InputStream stream = licence.getInputStream();
							byte[] bytes = new byte[1024];
							int length = 0;
							while ((length = stream.read(bytes)) != -1) {
								fos.write(bytes, 0, length);
							}
							fos.flush();
							stream.close();
							stdCompdrugprofileFromDb
									.setProfilePicAddr("upload/licence/" + name);
							stdCompdrugprofileFromDb
									.setProfilePicShortcutAddr("upload/licence/"
											+ name);
						}
						stdCompdrugprofileFromDb
								.setProfileName(stdCompdrugprofile
										.getProfileName());
						stdCompdrugprofileFromDb.setProfileStarttime(DateUtil
								.parseDate(stdCompdrugprofile
										.getProfileStarttimeStr()));
						stdCompdrugprofileFromDb.setProfileEndtime(DateUtil
								.parseDate(stdCompdrugprofile
										.getProfileEndtimeStr()));
						stdCompdrugprofileFromDb.setRemarks(stdCompdrugprofile
								.getRemarks());
						stdCompdrugprofileFromDb.setUpdDatetime(new Date());
						stdCompdrugprofileFromDb.setUpdUser(user.getId());

						prodDrugProfileManager.complainDrugProfile(
								stdCompdrugprofileFromDb, form, user);
						StdCompdrugprofileLog stdCompdrugprofileLog = new StdCompdrugprofileLog();
						BeanUtils.copyProperties(stdCompdrugprofileLog,
								stdCompdrugprofileFromDb);
						stdCompdrugprofileLog.setLogId(UUID.randomUUID()
								.toString());
						stdCompdrugprofileManager.save(stdCompdrugprofileLog);
						page.setMsg("操作成功");
						page.setSuccess(true);
					} else {
						page.setMsg("产品资质名称已被使用！");
						page.setSuccess(false);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
		} finally {
			if (fos != null) {
				try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return (page);
	}
	
	
	
	/**
	 * @category 查询药品资质澄清结果列表
	 * @date 2015年8月31日
	 * @param model
	 * @param form
	 * @return
	 */
	@RequestMapping("/toDrugProfileComplainResultList")
	public String toDrugProfileComplainResultList(Model model,
			ProdDrugProfileForm form) {
		log.info("enter toDrugProfileComplainList method!");
		model.addAttribute("form", form);
		return "/pro/project/prod/drugProfileComplainResultList";
	}

	/**
	 * @category 查询药品资质澄清结果列表
	 * @date 2015年8月31日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getDrugProfileComplainResultList")
	@ResponseBody
	public Pagination getDrugProfileComplainResultList(ProdDrugProfileForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setCompId(compId);
					page.setForm(form);
					prodDrugProfileManager.getDrugProfileComplainResultList(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	
	

	
	
	/**
	 * @category 药品资质申报页面
	 * @date 2015年8月30日
	 * @param model
	 * @param projId
	 * @return
	 */
	@RequestMapping("/toProdDrugListDeclare")
	public String toProdDrugListDeclare(Model model) {
		log.info("enter toAuditedProdDrugList method!");
		model.addAttribute("date", ParseDate.parseShortFormat(new Date()));	
		return "/pro/project/prod/auditedProdDrugListDeclare";
	}
	
	/**
	 * @category 药品资质申报页面查询
	 * @date 2015年8月30日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getProdDrugListDeclare")
	@ResponseBody
	public Pagination getProdDrugListDeclare(StdProdDrugInfoForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setProdCompId(compId);
					if (StringUtils.isNotBlank(user.getDefaultProjId())) {
						form.setProjId(user.getDefaultProjId());
					}
					page.setForm(form);
					prodDrugProfileManager.getProdDrugListDeclare(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 药品资审查看页面
	 * @date 2015年8月30日
	 * @param model
	 * @param projId
	 * @return
	 */
	@RequestMapping("/toProdDrugListDeclareSee")
	public String toProdDrugListDeclareSee(Model model) {
		log.info("enter toAuditedProdDrugList method!");
		return "/pro/project/prod/auditedProdDrugListDeclareSee";
	}
	
	/**
	 * @category 药品资审查看页面查询
	 * @date 2015年8月30日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getProdDrugListDeclareSee")
	@ResponseBody
	public Pagination getProdDrugListDeclareSee(StdProdDrugInfoForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setProdCompId(compId);
					if (StringUtils.isNotBlank(user.getDefaultProjId())) {
						form.setProjId(user.getDefaultProjId());
					}
					page.setForm(form);
					prodDrugProfileManager.getProdDrugListDeclareSee(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 药品资审澄清页面
	 * @date 2015年8月30日
	 * @param model
	 * @param projId
	 * @return
	 */
	@RequestMapping("/toProdDrugListClarify")
	public String toProdDrugListClarify(Model model) {
		log.info("enter toAuditedProdDrugList method!");
		model.addAttribute("date", ParseDate.parseShortFormat(new Date()));	
		return "/pro/project/prod/auditedProdDrugListClarify";
	}
	
	/**
	 * @category 药品资审澄清页面查询
	 * @date 2015年8月30日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getProdDrugListClarify")
	@ResponseBody
	public Pagination getProdDrugListClarify(StdProdDrugInfoForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setProdCompId(compId);
					if (StringUtils.isNotBlank(user.getDefaultProjId())) {
						form.setProjId(user.getDefaultProjId());
					} 
					page.setForm(form);
					prodDrugProfileManager.getProdDrugListClarify(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 药品资审澄清查看页面
	 * @date 2015年8月30日
	 * @param model
	 * @param projId
	 * @return
	 */
	@RequestMapping("/toProdDrugListClarifySee")
	public String toProdDrugListClarifySee(Model model) {
		log.info("enter toAuditedProdDrugList method!");
		return "/pro/project/prod/auditedProdDrugListClarifySee";
	}
	
	/**
	 * @category 药品资审澄清查看页面查询
	 * @date 2015年8月30日
	 * @param form
	 * @return
	 */
	@RequestMapping("/getProdDrugListClarifySee")
	@ResponseBody
	public Pagination getProdDrugListClarifySee(StdProdDrugInfoForm form) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = getUser();
			StdCompinfo compInfo = user.getInfo();
			if (compInfo != null) {
				String compId = compInfo.getCompId();
				if (StringUtils.isNotBlank(compId)) {
					form.setProdCompId(compId);
					if (StringUtils.isNotBlank(user.getDefaultProjId())) {
						form.setProjId(user.getDefaultProjId());
					}
					page.setForm(form);
					prodDrugProfileManager.getProdDrugListClarifySee(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}

}
